<html>
<head><meta charset="utf-8"><title>Underspecified language semantics of match arm guard · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html">Underspecified language semantics of match arm guard</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204993884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/204993884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#204993884">(Jul 25 2020 at 08:06)</a>:</h4>
<p>cc <a href="https://github.com/rust-lang/rust/issues/74566">#74566</a></p>
<p>On <a href="https://doc.rust-lang.org/nightly/reference/expressions/match-expr.html#match-expressions">reference</a>, match arm guard is <code>if</code> expression, but <code>if</code> expr <a href="https://doc.rust-lang.org/nightly/reference/expressions/if-expr.html#if-expressions">doesn't allow</a> struct expression.</p>
<p>But the restrictions on match guard is not enforced, so it cases breakage when enforced: <a href="https://github.com/rust-lang/rust/pull/74566#issuecomment-663797198">https://github.com/rust-lang/rust/pull/74566#issuecomment-663797198</a></p>



<a name="205013299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205013299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205013299">(Jul 25 2020 at 17:34)</a>:</h4>
<p>Interesting. If people are using this, I don't think we should change it, even if we think it makes for cleaner parsing.</p>



<a name="205013687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205013687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205013687">(Jul 25 2020 at 17:44)</a>:</h4>
<p>What restriction? The match guard is not an <em>IfExpression</em>.</p>



<a name="205034446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205034446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205034446">(Jul 26 2020 at 03:50)</a>:</h4>
<p>Sorry if my language doesn't clear. but the reference doesn't clear either (at least to me).<br>
The Reference says that <br>
<a href="/user_uploads/4715/WqBEj2f9QvflktlBvIwb-H3b/image.png">image.png</a> <br>
Does it mean that match guard is <code>if</code> + expression (1), or <em>IfExprssion</em> (2)?<br>
If it is <em>IfExpression</em>, then <br>
<a href="/user_uploads/4715/66TUrj4KyVB4RQtYcIULjFVb/image.png">image.png</a><br>
if it is (1), what expressions could be after <code>if</code>? Can <em>LiteralExpression</em> be?</p>
<div class="message_inline_image"><a href="/user_uploads/4715/WqBEj2f9QvflktlBvIwb-H3b/image.png" title="image.png"><img src="/user_uploads/4715/WqBEj2f9QvflktlBvIwb-H3b/image.png"></a></div><div class="message_inline_image"><a href="/user_uploads/4715/66TUrj4KyVB4RQtYcIULjFVb/image.png" title="image.png"><img src="/user_uploads/4715/66TUrj4KyVB4RQtYcIULjFVb/image.png"></a></div>



<a name="205034677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205034677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205034677">(Jul 26 2020 at 03:59)</a>:</h4>
<p>That looks like (1) to me. I don't understand your follow-up question - shouldn't any production allowed by <code>Expression</code> be allowed?</p>



<a name="205034938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205034938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205034938">(Jul 26 2020 at 04:07)</a>:</h4>
<p>Sorry. I see my mistake. My language sometimes doesn't match my thoughts.<br>
What I mean is that can match guard has the same conditional expression as <code>IfExpression</code> or <code>IfLetExpression</code>?</p>



<a name="205038775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205038775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205038775">(Jul 26 2020 at 06:26)</a>:</h4>
<p>I opened  <a href="https://github.com/rust-lang/reference/issues/855">https://github.com/rust-lang/reference/issues/855</a> to discuss about introducing condition expression (?) to IfExpression syntax?</p>



<a name="205073588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205073588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205073588">(Jul 27 2020 at 00:28)</a>:</h4>
<p>No, <code>if</code> <em>Expression</em> is different from <em>IfExpression</em>; if it were the same, you could put an <code>else</code> into a match guard</p>



<a name="205075558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Underspecified%20language%20semantics%20of%20match%20arm%20guard/near/205075558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Underspecified.20language.20semantics.20of.20match.20arm.20guard.html#205075558">(Jul 27 2020 at 01:30)</a>:</h4>
<p>Sorry. When I say <code>IfExpression</code>, what I mean is <code>if</code> + condition expression of <code>IfExpression</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>